home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / SysIO / exit.c < prev    next >
C/C++ Source or Header  |  1990-04-07  |  1KB  |  50 lines

  1. /*
  2.  * Libraries and headers for PDC release 3.3 (C) 1989 Lionel Hummel.
  3.  * PDC Software Distribution (C) 1989 Lionel Hummel and Paul Petersen.
  4.  * PDC I/O Library (C) 1987 by J.A. Lydiatt.
  5.  *
  6.  * This code is freely redistributable upon the conditions that this 
  7.  * notice remains intact and that modified versions of this file not
  8.  * be included as part of the PDC Software Distribution without the
  9.  * express consent of the copyright holders.  No warrantee of any
  10.  * kind is provided with this code.  For further information, contact:
  11.  *
  12.  *  PDC Software Distribution    Internet:                     BIX:
  13.  *  P.O. Box 4006             or hummel@cs.uiuc.edu            lhummel
  14.  *  Urbana, IL  61801-8801       petersen@uicsrd.csrd.uiuc.edu
  15.  */
  16.  
  17. /*    exit.c
  18.  *
  19.  *    exit(returnCode)    - Cleans up PDC's I/O
  20.  *    int returnCode;     - The return code passed back to the startup module
  21.  */
  22.  
  23. #include <fcntl.h>
  24.  
  25. extern void _exit(), close();
  26. extern void (*_fcloseall)(), (*_freeall)();
  27.  
  28. extern short _numdev;
  29. extern struct _device *_devtab;
  30.  
  31. exit(returnCode)
  32. int returnCode;        
  33. {
  34.     int fd;
  35.  
  36.     if ( _fcloseall != 0 )
  37.         (*_fcloseall)();
  38.  
  39.     if (_devtab != 0) {
  40.         for (fd = 0 ; fd < _numdev ; ++fd)
  41.             close( fd );
  42.         free(_devtab);
  43.     }
  44.  
  45.     if ( _freeall != 0 )
  46.         (*_freeall)(); /* Free any malloc()ed memory */    
  47.  
  48.     _exit ((long)returnCode);
  49. }
  50.